# coding=utf-8

from lxml import etree

a = u'''


<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<base href="http://www.cpppc.org:8082/efmisweb/">
<!-- 龙图的JS -->

<script type="text/javascript" src="getScript.do?url=static/ext.lt/js/frameworksupport.gzjs&version=1"></script>
<script type="text/javascript" src="getScript.do?url=static/ext.lt/js/ltext_core.gzjs&version=1"></script>

<!--wanhm 2015/7/6
<script type="text/javascript" src="static/ext.lt/js/datatable3.0.gzjs"></script>
<script type="text/javascript" src="static/ext.lt/js/editdatatable.gzjs"></script>
<script type="text/javascript" src="getScript.do?url=static/ext.lt/js/formulasdatatable.gzjs&version=1"></script>
-->

<!--添加jquery -->
<script type="text/javascript" src="getScript.do?url=static/jquery/jquery-1.9.0.min.gzjs&version=1"></script>

<!--
<script type="text/javascript" src="static/jquery/jquery-1.9.0.min.js"></script>
-->
<script type="text/javascript">
var basePath = "http://www.cpppc.org:8082/efmisweb/";
var systemStyle = "default";
var fileServerPort = "7002";
var systemTitle = "金财工程应用支撑平台";
var skinConfig={
    style: "default"

};
var tokenID =  "null";
var moduleId =  "null";
var tokenParam = "tokenid=null";
function setTokenID(e) {
	var url = e.url;
	if (e.dataType != null && e.dataType.toLowerCase() == 'script') {
		return e;
	}
	if (url.indexOf("?") == -1) {
		url = url + "?" + tokenParam;
	} else if (url.indexOf("tokenid") == -1) {
		url = url + "&" + tokenParam;
	}
	e.url = url;
	return e;
}

function getPort(){
	return ":7001/";
}
 /**
  Hq.modules.version={
  "static/ext.lt/js/editpanel.js":"1",
  "static/json/json2.js":"3"
  };
  */
  // Hq.modules.version="2"

 </script>
</head>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

		<link rel="stylesheet" type="text/css" href="static/hqui/themes/metro/easyui.css">
		<link rel="stylesheet" type="text/css" href="static/hqui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="static/hqui/themes/icon_hq.css">
		<link rel="stylesheet" type="text/css" href="css/ppp/project/projectTable.css">
		<link rel="stylesheet" type="text/css" href="style/default/css/default.css" />
		<link href="css/map/base.css" rel="stylesheet" type="text/css" />
		<link href="css/map/layout.css" rel="stylesheet" type="text/css" />

		<script type="text/javascript" src="static/hqui/jquery.easyui.min.gzjs"></script>
		<script type="text/javascript" src="static/hqui/locale/easyui-lang-zh_CN.js"></script>

		<title>项目详情</title>

	<style type="text/css">
	.view_table tr {height: 40px;}
	</style>

	<style type="text/css">
		.view_table {
		    border-collapse: collapse;
		    line-height: 14px;
		    width: 100%;
		    color: #7D6666;
		    margin-top: 15px;
		}
		.view_table tr td.view_field_label {
		    text-align: center;
		    padding-right: 5px;
		    background: #FFFFFF;
		    /* background: #F7F7F7; */
		    width: 20%;
		    font-weight: bold;
		}

		.view_table tr td.view_field_con {
		    text-align: center;
		    padding-left: 8px;
		    width: 80%;
		}
	</style>
</head>

<body class="background">
	<div class="header">
		<div class="margin">
			<div class="logo">
				<img src="images/map/logo.png" />
			</div>
			<div class="CPPPC">
				<img src="images/map/CPPPC.png" />
			</div>
		</div>
	</div>
	<div class="line"></div>
	<div class="wrap" style="padding-bottom: 20px;">
		<div class="Over">
			<div class="dist">
				<div class="att" style="margin-top: -50px;">
					<center><font size="6" color="#004C93"><b>海淀区循环经济产业园再生能源发电厂</b></font> </center>

					<table class="view_table">

						<tr>
							<td class="view_field_label">所在地区</td>
							<td class="view_field_con">北京市

									--> 市辖区


									--> 海淀区

							</td>
						</tr>
						<tr>
							<td class="view_field_label">所属行业</td>
							<td class="view_field_con">能源->垃圾发电</td>
						</tr>
						<tr>
							<td class="view_field_label">投资金额</td>
							<td class="view_field_con">       152,548万元</td>
						</tr>

						<tr>
							<td class="view_field_label">PPP实施阶段</td>
							<td class="view_field_con">执行阶段</td>
						</tr>
						<tr>
							<td class="view_field_label">拟合作期限</td>
							<td class="view_field_con">30年</td>
						</tr>
						<tr>
							<td class="view_field_label">项目运作方式</td>
							<td class="view_field_con">其他</td>
						</tr>
						<tr>
							<td class="view_field_label">回报机制</td>
							<td class="view_field_con">政府付费</td>
						</tr>
						<tr>
							<td class="view_field_label">发起时间</td>
							<td class="view_field_con">2013-12-31</td>
						</tr>
						<tr>
							<td class="view_field_label">发起类型</td>
							<td class="view_field_con">政府发起</td>
						</tr>

						<tr>
							<td class="view_field_label">项目概况</td>
							<td class="view_field_con" style="text-align: left">
								<div style="text-indent: 25px; line-height:2;">北京市海淀区循环经济产业园再生能源发电厂项目（下称本项目）规划选址位于苏家坨镇大工村东侧，由海淀区属国有企业北京绿海能环保有限责任公司负责建设。本项目于2012年6月开工建设，计划2014年完成设备安装和全部结构封顶，2015年投入运营。项目总投资概算15.2548亿元。其中，市政府安排固定资产投资5.0048亿元，中央政府安排预算内投资1亿元,其余由海淀区政府自筹解决。为筹措本项目建设资金，经市发改委同意，区政府决定采用在建项目的PPP(政府与企业合作投资建设)特许经营的模式进行融资、建设和运营。本项目设计规模为日处理生活垃圾2500吨，其中焚烧经预处理的可燃垃圾未1800吨/日，厌氧发酵预处理厨余垃圾400吨。</div>
							</td>
						</tr>
						<tr>
							<td class="view_field_label">联系人</td>
							<td class="view_field_con">刘利民</td>
						</tr>
						<tr>
							<td class="view_field_label">联系人电话</td>
							<td class="view_field_con">88487218</td>
						</tr>
						<tr>
							<td class="view_field_label">示范/推介项目级别</td>
							<td class="view_field_con">其它</td>
						</tr>
						<tr>
							<td class="view_field_label">示范项目批次</td>
							<td class="view_field_con"></td>
						</tr>
					</table>

				</div>


			</div>
		</div>
	</div>
	<div class="footer">
		<div class="mar">
			<div class="img">
				<img src="images/map/footer-img.png" width="50" height="62" />
			</div>
			<div class="dis">
				<div class="guild">
					<a href="javascript:void(0);">联系我们</a><i>|</i><a href="javascript:void(0);">加入我们</a><i>|</i><a href="javascript:void(0);">友情链接</a><i>|</i><a
						href="javascript:void(0);">网站地图</a>
				</div>
				<div class="copyr">
					政府和社会资本合作中心 © · All Rights Reserved <br />
					京ICP备07504037号-2 京公网安备110102005872号-2
				</div>
			</div>
		</div>
	</div>
	<div id="code">
		<div class="con">
			<img src="images/map/code.png" width="105" height="135" />
		</div>
		<div class="con" style="margin-top:10px;"><img src="images/map/ppp_ma.png" width="105" height="135" /></div>
	</div>


	<script type="text/javascript" src="static/hqui/jquery.easyui.min.gzjs"></script>
</body>
</html></html>



'''

tree = etree.HTML(a)
div = tree.xpath('.//div[@class="Over"]')
#print div[0].xpath('string(.)')


xpaths = {'项目名称':'string(.//center)',
 '所在地区':'string(.//table//tr[1]/td[2])',
 '所属行业': 'string(.//table//tr[2]/td[2])',
 '投资金额': 'string(.//table//tr[3]/td[2])',
 'PPP实施阶段': 'string(.//table//tr[4]/td[2])',
 '拟合作期限': 'string(.//table//tr[5]/td[2])',
 '项目运作方式': 'string(.//table//tr[6]/td[2])',
 '回报机制': 'string(.//table//tr[7]/td[2])',
 '发起时间': 'string(.//table//tr[8]/td[2]/text())',
 '发起类型': 'string(.//table//tr[9]/td[2])',
 '项目概况': 'string(.//table//tr[10]/td[2])',
 '联系人': 'string(.//table//tr[11]/td[2])',
 '联系人电话': 'string(.//table//tr[12]/td[2]/text())',
 '示范/推介项目级别': 'string(.//table//tr[13]/td[2])',
 '示范项目批次': 'string(.//table//tr[14]/td[2]/text())',
 }

for x in xpaths:
    print x, div[0].xpath(xpaths[x])

# print "项目名称:", div[0].xpath('string(.//center)')
# print "所在地区", div[0].xpath('string(.//table/tr[1]/td[2])')
# print "所属行业", div[0].xpath('string(.//table/tr[2]/td[2])')
# print "投资金额", div[0].xpath('string(.//table/tr[3]/td[2])')
# print "PPP实施阶段", div[0].xpath('string(.//table/tr[4]/td[2])')
# print "拟合作期限", div[0].xpath('string(.//table/tr[5]/td[2])')
# print "项目运作方式", div[0].xpath('string(.//table/tr[6]/td[2])')
# print "回报机制", div[0].xpath('string(.//table/tr[7]/td[2])')
# print "发起时间", div[0].xpath('string(.//table/tr[8]/td[2])')
# print "发起类型", div[0].xpath('string(.//table/tr[9]/td[2])')
# print "项目概况", div[0].xpath('string(.//table/tr[10]/td[2])')
# print "联系人", div[0].xpath('string(.//table/tr[11]/td[2])')
# print "联系人电话", div[0].xpath('string(.//table/tr[12]/td[2])')
# print "示范/推介项目级别", div[0].xpath('string(.//table/tr[13]/td[2])')
# print "示范项目批次", div[0].xpath('string(.//table/tr[14]/td[2])')

